package com.example.xinhuaxin.dao;

import com.example.xinhuaxin.entity.Card;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CardDao {
//    获取所有银行卡
    @Select("select * from CARD")
    public List<Card> getCardList();
//    查找银行卡信息
    @Select("select * from CARD where CARD_ID = #{card_id}")
    public Card getCardInfo(int card_id);
//    银行卡绑定
    @Insert("insert into USER_CARD (ID, USER_ID, CARD_ID, STATE) values (#{id}, #{user_id}, #{card_id}, #{state})")
    public void bindCard(String id, String user_id, int card_id, int state);
//    银行卡绑定信息
    @Select("select * from USER_CARD where USER_ID = #{user_id} and CARD_ID = #{card_id}")
    public String getBindInfo(String user_id, int card_id);
//    银行卡注销
    @Update("update USER_CARD set state = 0 where ID = #{id}")
    public void closeAccount(String id);
}
